home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / Utils.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.8 KB  |  183 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Utils.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef UTILS_H
  13. #define UTILS_H
  14.  
  15. #ifndef FWGC_H
  16. #include "FWGC.h"
  17. #endif
  18.  
  19. // ----- OS Layer -----
  20.  
  21. #ifndef FWPOINT_H
  22. #include "FWPoint.h"
  23. #endif
  24.  
  25. #ifndef FWINK_H
  26. #include "FWInk.h"
  27. #endif
  28.  
  29. #ifndef FWSTYLE_H
  30. #include "FWStyle.h"
  31. #endif
  32.  
  33. #ifndef SLGRDEF_H
  34. #include "SLGrDef.h"
  35. #endif
  36.  
  37. #ifndef FWSUSINK_H
  38. #include "FWSUSink.h"
  39. #endif
  40.  
  41. // ----- FOundation Layer -----
  42.  
  43. #ifndef FWSTDDEF_H
  44. #include "FWStdDef.h"
  45. #endif
  46.  
  47. //========================================================================================
  48. //    Forward Declarations
  49. //========================================================================================
  50.  
  51. class FW_CGraphicContext;
  52. class FW_CRect;
  53. class FW_CStorageUnitSink;
  54. class FW_CCloneInfo;
  55.  
  56. class CDrawPart;
  57.  
  58. //========================================================================================
  59. //    Class CGrid
  60. //========================================================================================
  61. // index, row and column are 0 based
  62. //
  63. //    Index Example         0 | 1 | 2
  64. //                        ---------
  65. //                        3 | 4 | 5
  66. //
  67.  
  68. class CGrid
  69. {
  70. public:
  71.     CGrid(unsigned short rows, unsigned short columns, 
  72.          const FW_CPoint& position, 
  73.          const FW_CPoint& cellInterior, 
  74.          FW_Fixed penSize);
  75.  
  76.     FW_Boolean        FindCell(const FW_CPoint& where, unsigned long& index) const;
  77.     FW_Boolean        FindCell(const FW_CPoint& where, unsigned short& row, unsigned short& column) const;
  78.     
  79.     void            GetCellInterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
  80.     void            GetCellInterior(unsigned long index, FW_CRect& rect) const;
  81.  
  82.     void            GetCellExterior(unsigned short row, unsigned short column, FW_CRect& rect) const;
  83.     void            GetCellExterior(unsigned long index, FW_CRect& rect) const;
  84.  
  85.     void            GetExteriorGridRect(FW_CRect& rect) const;
  86.     void            GetInteriorGridRect(FW_CRect& rect) const;
  87.     
  88.     unsigned long    GetIndex(unsigned short row, unsigned short column) const
  89.                         {return row * fColumns + column;}
  90.                     
  91.     void            GetRowColumn(unsigned long index, unsigned short& row, unsigned short& column) const;
  92.  
  93.     void            DrawGridBorders(FW_CGraphicContext& gc, const FW_CInk& ink = FW_kNormalInk, const FW_CStyle& style = FW_kNormalStyle);
  94.     
  95. private:
  96.     unsigned short    fRows;
  97.     unsigned short    fColumns;
  98.     FW_CPoint        fPosition;
  99.     FW_CPoint        fCellSize;
  100.     FW_Fixed        fHalfPenSize;
  101. };
  102.  
  103. //========================================================================================
  104. //    Class CWidget
  105. //========================================================================================
  106.  
  107. class CWidget
  108. {
  109. public:
  110.     CWidget(FW_ResourceID resID);
  111.     ~CWidget();
  112.     
  113.     void    Render(FW_CGraphicContext& gc, const FW_CRect& rect); 
  114.  
  115. private:
  116.     FW_ResourceID         fResID;
  117.  
  118. };
  119.  
  120. //========================================================================================
  121. //    class CDrawReadableStream
  122. //========================================================================================
  123. //    This is a hack until I can pass data through the archiver
  124.  
  125. class CDrawReadableStream : public FW_CReadableStream
  126. {
  127. public:
  128.  
  129.     FW_DECLARE_AUTO(CDrawReadableStream)
  130.     
  131.     CDrawReadableStream(Environment* ev, 
  132.                         CDrawPart* drawPart, 
  133.                         FW_ORandomAccessSink* sink, 
  134.                         FW_OStorageUnitSink* suSink,
  135.                         FW_CCloneInfo* cloneInfo);
  136.     virtual ~CDrawReadableStream();
  137.     
  138.     Environment*            GetEnvironment() const
  139.                                 {return fEnvironment;}
  140.     CDrawPart*                GetDrawPart() const
  141.                                 {return fDrawPart;}
  142.     FW_CCloneInfo*            GetCloneInfo() const
  143.                                 {return fCloneInfo;}
  144.     ODStorageUnitView*        GetStorageUnitView() const
  145.                                 {return fSUSink->GetStorageUnitView(fEnvironment);}
  146. private:
  147.     Environment*            fEnvironment;
  148.     CDrawPart*                fDrawPart;
  149.     FW_OStorageUnitSink*    fSUSink;
  150.     FW_CCloneInfo*            fCloneInfo;
  151. };
  152.  
  153. //========================================================================================
  154. //    class CDrawReadableStream
  155. //========================================================================================
  156. //    This is a hack until I can pass data through the archiver
  157.  
  158. class CDrawWritableStream : public FW_CWritableStream
  159. {
  160. public:
  161.  
  162.     FW_DECLARE_AUTO(CDrawWritableStream)
  163.     
  164.     CDrawWritableStream(Environment* ev, 
  165.                         FW_ORandomAccessSink* sink, 
  166.                         FW_OStorageUnitSink* suSink,
  167.                         FW_CCloneInfo* cloneInfo);
  168.     virtual ~CDrawWritableStream();
  169.     
  170.     Environment*            GetEnvironment() const
  171.                                 {return fEnvironment;}
  172.     FW_CCloneInfo*            GetCloneInfo() const
  173.                                 {return fCloneInfo;}
  174.     ODStorageUnitView*        GetStorageUnitView() const
  175.                                 {return fSUSink->GetStorageUnitView(fEnvironment);}
  176. private:
  177.     Environment*            fEnvironment;
  178.     FW_OStorageUnitSink*    fSUSink;
  179.     FW_CCloneInfo*            fCloneInfo;
  180. };
  181.  
  182. #endif
  183.